package logic

import (
	"api/model/mysql"
	"context"

	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserStatusLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserStatusLogic {
	return &UserStatusLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserStatusLogic) UserStatus(in *house.UserStatusRequest) (*house.UserStatusResponse, error) {
	// todo: add your logic here and delete this line

	var u mysql.User
	mysql.DB.Debug().Where("user_status=?", in.UserStatus).Find(&u)

	if u.UserStatus != 1 {
		logx.Error("用户信息审核不通过,不能发布房源")
		return nil, nil
	}

	return &house.UserStatusResponse{
		Type: true,
	}, nil
}
